package com.zhan.webflux.filters;

import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

/*
 *@Description<p></p>
 *@Author gz
 *@CreateTime 2025/7/22 19:43
 *@CopyRight @2021-2025 卓望信息技术（北京）公司
 */
@Component
public class MyFilter implements WebFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        ServerHttpResponse response = exchange.getResponse();
        System.out.println("filer 前执行");
        Mono<Void> filter = chain.filter(exchange);
        filter.doFinally(
                s -> {
                    System.out.println("filter finally 执行");
                }
        );
        System.out.println("file 后执行。。。。。。");
        return filter;
    }
}
